package liportest.dependenttest;


import liportest.model.OrderModel;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@Slf4j
public class OrderController {

     final IOrderService orderService;


    @GetMapping()
    public String getOrders() {
        return orderService.getOrders().toString();
    }


    @GetMapping("start")
    public String startOrder() {
        final OrderModel orderModel = orderService.create();
        log.info(orderModel.toString());
        return orderModel.toString();
    }

    @GetMapping("pay/{id}")
    public String payOrder(@PathVariable Integer id) {
        final OrderModel orderModel = orderService.pay(id);
        log.info(orderModel.toString());
        return orderModel.toString();
    }

    @GetMapping("deliver/{id}")
    public String deliverOrder(@PathVariable Integer id) {
        final OrderModel orderModel = orderService.deliver(id);
        log.info(orderModel.toString());
        return orderModel.toString();
    }

    @GetMapping("receive/{id}")
    public String receiveOrder(@PathVariable Integer id) {

        final OrderModel orderModel = orderService.receive(id);
        log.info(orderModel.toString());
        return orderModel.toString();
    }

}
